package hos.demo

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.widget.TextView
import hos.bus.LiveBus

class MainActivity : AppCompatActivity() {

    private val content by lazy { findViewById<TextView>(R.id.content) }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        LiveBus.with<String>("content").observe(this){
            Log.d("TAG", "content: $it")
            content.text = it
        }
        LiveBus.once<String>("contentOnce").observe(this) {
            Log.d("TAG", "contentOnce: $it")
            content.text = it
        }
        content.setOnClickListener {
            startActivity(Intent(this,BusActivity::class.java))
        }
    }
}